package com.memmana.controller;
/*
 * 控制层，使用了组件注解，会被扫描到（见Spring MVC配置文件之组件扫描）
 */
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.memmana.entity.News;
import com.memmana.service.NewsService;

@Controller
@RequestMapping({"/Home", "/", "" })
public class HomeController {
	
	@Autowired
	private NewsService newsService;  //注解注入服务层对象
	
	@RequestMapping({"", "/", "/index" })
	public String index(Model model) {
		List<News> news = newsService.queryAllNews();
		model.addAttribute("newsList", news);
		return "home/index";
	}
}

